<%-- 
    Document   : manage
    Created on : Nov 5, 2011, 3:10:48 PM
    Author     : Yudi Retanto
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/header.jsp"></jsp:include>
<h1>
    Manage Shipping
</h1>
<script type="text/javascript">
    function changeCity(id){
        city = $('#'+id+'City').val();
        if(city != 0){
            $('#'+id+'Pool').load('./shuttles?action=manage&get=pool&city='+city);
            $('#defCity').remove();
        }        
    }
    function changePool(id){
        pool = $('#'+id+'Pool').val();
        if(pool != 0){
            $('.defPool').remove();
        }        
    }
    function search(){
        poolS=$("#sPool").val();
        poolE=$("#ePool").val();
        if(poolS < 0){
            alert("Tolong pilih pool keberangkatan");
        } else if(poolE < 0){
            alert("Tolong pilih pool tujuan");
        } else {
            $('#manageSched').load('./shippings?action=manage&get=shipping&ori='+poolS+'&dest='+poolE);
        }
        return false;
    }
</script>
<form onsubmit="return search();">
<table id="manageForm">
    <tr>
        <td style="width: 20%;">
            <label for="name">Kota Keberangkatan :</label>
        </td>
        <td>
            <select id="sCity" name="city" onchange="changeCity('s');">
                <option id="defCity" value="0" selected="selected">Pilih Kota Keberangkatan</option>
                <c:forEach items="${cities}" var="city">
                    <option value="${city.getId()}">${city.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="name">Pool Keberangkatan :</label>
        </td>
        <td>
            <select id="sPool" name="pool" onchange="changePool('s');">
            </select>
        </td>
    </tr>
    <tr>
        <td style="width: 20%;">
            <label for="name">Kota Keberangkatan :</label>
        </td>
        <td>
            <select id="eCity" name="city" onchange="changeCity('e');">
                <option id="defCity" value="0" selected="selected">Pilih Kota Keberangkatan</option>
                <c:forEach items="${cities}" var="city">
                    <option value="${city.getId()}">${city.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="name">Pool Keberangkatan :</label>
        </td>
        <td>
            <select id="ePool" name="pool" onchange="changePool('e');">
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <input type="submit" name="submit" value="submit"/>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <table id="manageSched">
                
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <a href="./shippings?action=manage&mode=add">Tambah Jadwal</a>
        </td>
    </tr>
</table>
</form>
<jsp:include page="/footer.jsp"></jsp:include>
